#import "ALEditTemplateOptionsBarView.h"

static const CGFloat ALEditTemplateOptionsBarViewCornerRadius = 8.0f;
static const CGFloat ALEditTemplateOptionsBarViewDividerPosition = 40.0f;
static NSGradient *ALEditTemplateOptionsBarViewBackgroundGradientNormal;
//static NSGradient *ALEditTemplateOptionsBarViewBackgroundGradientHighlighted;
static NSColor *ALEditTemplateOptionsBarViewBorderColor;

@implementation ALEditTemplateOptionsBarView

+(void)initialize {
	ALEditTemplateOptionsBarViewBackgroundGradientNormal = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.529 alpha:1.000] endingColor:[NSColor colorWithCalibratedWhite:0.670 alpha:1.000]];
	ALEditTemplateOptionsBarViewBorderColor = [NSColor colorWithCalibratedWhite:0.3f alpha:1.0f];
}

-(void)drawRect:(NSRect)dirtyRect {
	NSRect bounds = [self bounds];
	NSBezierPath *roundRect = [NSBezierPath bezierPathWithRoundedRect:bounds xRadius:ALEditTemplateOptionsBarViewCornerRadius yRadius:ALEditTemplateOptionsBarViewCornerRadius];
	[ALEditTemplateOptionsBarViewBackgroundGradientNormal drawInBezierPath:roundRect angle:90.0f];
	[ALEditTemplateOptionsBarViewBorderColor setStroke];
	[roundRect stroke];
	CGFloat leftX = round(NSMinX(bounds) + ALEditTemplateOptionsBarViewDividerPosition) + 0.5f;
	CGFloat rightX = round(NSMaxX(bounds) - ALEditTemplateOptionsBarViewDividerPosition) + 0.5f;
	[NSBezierPath strokeLineFromPoint:NSMakePoint(rightX, 0) toPoint:NSMakePoint(rightX, NSMaxY(bounds))];
	[NSBezierPath strokeLineFromPoint:NSMakePoint(leftX, 0) toPoint:NSMakePoint(leftX, NSMaxY(bounds))];
}

@end
